import { getCinemaListService } from "../services/maizuo";

export default {
  namespace: "maizuo",
  state: {
    isShow: true,
    list: [],
  },
  effects: {
    *getCinemaList(action, { call, put }) {
      // eslint-disable-line
      var res = yield call(getCinemaListService);
      console.log("异步service 请求返回数据为", res.data);
      yield put({
        type: "changeCinemaList",
        payload: res.data.data.cinemas,
      });
    },
  },

  reducers: {
    hide(state, action) {
      return { ...state, isShow: false };
    },
    show(state, action) {
      return { ...state, isShow: true };
    },
    changeCinemaList(state, action) {
      const data = action.payload;
      return { ...state, list: data };
    },
  },

  subscriptions: {
    setup(dispatch, history) {
      console.log("我在初始化");
      console.log("dispatch", dispatch);
      console.log("history", history);
    },
  },
};
